import QtQuick 1.1
import com.nokia.meego 1.0

Page {
    //pocetna stranica na kojoj prikazujemo izbornik, zato se i zove MenuPage, ne?

    id: menuPage

    property variant aboutDialog

    Image {
        id: bacground
        anchors.fill: parent
        source: "qrc:/images/pozadina1.png"
        fillMode: "PreserveAspectCrop"
    }

    Item {
        id: rectangleUp
        height: parent.height*0.5 //0.5
        width: parent.width

        anchors {
            horizontalCenter: parent.horizontalCenter
            top: parent.top
        }

        Image {
            id: logo
            source: "qrc:/images/ducanko.png"
            width: parent.width*0.7
            fillMode: "PreserveAspectCrop"

            anchors {
                centerIn: parent
            }

            visible: true
        }
    }

    Button{
        id: buttonAllLists
        anchors {
            horizontalCenter: parent.horizontalCenter
            top: rectangleUp.bottom
            topMargin: 10
        }
        text: qsTr("All lists");
        onClicked: appWindow.pageStack.push(allListsPage);
    }

    Button{
        id: buttonEditDatabase
        anchors {
            horizontalCenter: parent.horizontalCenter
            top: buttonAllLists.bottom
            topMargin: 10
        }
        text: qsTr("Edit database")
        onClicked: appWindow.pageStack.push(editDatabasePage);
    }

    Button{
        id: buttonSettings
        anchors {
            horizontalCenter: parent.horizontalCenter
            top: buttonEditDatabase.bottom
            topMargin: 10
        }
        text: qsTr("Settings")
        onClicked:{
            qmlHandler.refreshLanguages()
            appWindow.pageStack.push(settingsPage)
        }

    }

    Button{
        id: buttonAbout
        anchors {
            horizontalCenter: parent.horizontalCenter
            top: buttonSettings.bottom
            topMargin: 10
        }
        text: qsTr("About")
        onClicked: {//appWindow.pageStack.push(aboutPage);
            var component = Qt.createComponent("AboutDialog.qml")
            aboutDialog = component.createObject(menuPage)
            aboutDialog.open()
        }
    }

    Button{
        id: buttonExit
        anchors {
            horizontalCenter: parent.horizontalCenter
            top: buttonAbout.bottom
            topMargin: 10
        }
        text: qsTr("Exit")
        onClicked: Qt.quit() //provjeriti dal se tak dobro gasi
    }

    //stanje ovisi o orijentaciji
    states: [
        State {
            name: "inLandscape"
            when: !appWindow.inPortrait
            PropertyChanges {
                target: rectangleUp
                height: rectangleUp.parent.height*0.25
            }
            PropertyChanges {
                target: logo
                width: logo.parent.height*0.8
            }
        },
        State {
            name: "inPortrait"
            when: appWindow.inPortrait
            PropertyChanges {
                target: rectangleUp
                height: rectangleUp.parent.height*0.5
            }
            PropertyChanges {
                target: logo
                width: logo.parent.width*0.7
            }
        }
    ]

    function translate(){
        buttonAllLists.text = qsTr("All lists");
        buttonEditDatabase.text = qsTr("Edit database");
        buttonSettings.text = qsTr("Settings");
        buttonAbout.text = qsTr("About");
        buttonExit.text = qsTr("Exit");
    }

    //komponente koje ubacujemo na stack
    Component{id: allListsPage; AllListsPage {}}
    //Component{id: aboutPage; AboutPage {}}
    Component{id: editDatabasePage; EditDatabasePage {}}
    Component{id: settingsPage; SettingsPage {}}
}
